package chapter10.eg11;

import java.util.Arrays;

public class OrderFactory {

  public static Order create(long orderNumber) {
    Order order = new Order();
    order.setOrderNumber(orderNumber);
    order.setBillTo(createAddress("street1", "street2", "95738", "San Francisco", "CA", "America"));
    order.setShipTo(createAddress("street1", "street2", "96444", "New York", "CA", "America"));
    order.setCustomer(createCustomer());
    order.setShipping(Shipping.INFORMATIONAL_EXPRESS);
    order.setTotal(100f);
    return order;
  }

  private static Customer createCustomer() {
    Customer customer = new Customer();
    customer.setFirstName("li");
    customer.setLastName("linfeng");
    customer.setMiddleName(Arrays.asList("middleName"));
    customer.setCustomerNumber(1);
    return customer;
  }

  private static Address createAddress(String street1, String street2, String postCode,
    String city, String state, String country) {
    Address address = new Address();
    address.setStreet1(street1);
    address.setStreet2(street2);
    address.setCity(city);
    address.setState(state);
    address.setPostCode(postCode);
    address.setCountry(country);
    return address;
  }

}
